/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Min0
 */
public class getMax
{

    /** Creates a new instance of GetMax */
    public getMax()
    {
    }
    //getMax is for the primary key in the table			

    public static int getMaxId(String query)
    {
        ResultSet results;
        int id = -1;
        try
        {
            Statement stmt = DBConnection.getInstance().getDBcon().createStatement();
            results = stmt.executeQuery(query);
            if (results.next())
            {
                id = results.getInt(1);
            }
        }//slut try	
        catch (Exception e)
        {
            System.out.println("Query exception: Error in reading maxid" + e);
        }
        return id;
    }
    /*
    public static void cleanDatabase(String query)
    {
        //String query = "DELETE * FROM "+tableName;

        try
        {
            Statement stmt = DBConnection.getInstance().getDBcon().createStatement();
            stmt.setQueryTimeout(5);
            stmt.executeUpdate(query);
            stmt.close();
        }//slut try	
        catch (Exception e)
        {
            System.out.println("Query exception: Error in reading maxid" + e);
        }
    }*/
}
